<%@ include file="../common.jsp"%>

<script type="text/javascript">
	$(document).ready(
		
			function() {
				$("#saveDepartmentDetails").attr("action",'<c:url value="/saveDepartmentEditDetails.htm"></c:url>');

			});
		
</script>

<div>
	<c:choose>
		<c:when test="${size > 0}">
			<form name="editDepartmentDetails" id="editDepartmentDetails">
				<div style="width: 60%;">
					<table class="viewDetails">
						<tr class="adminTableMainHeaderColor tableChildHeaderFont">
							<th colspan="4" align="center"> LIST OF DEPARTMENT(S) </th>
						</tr>
						<tr class="heading">
							<th> Select </th>
							<th> Name </th>
							<th> Code </th>
						</tr>	
					
						<c:forEach items="${departmentsList}" var="departmentsList" varStatus="loop">
							<c:set var="tabColor" value="odd"></c:set>
						     	<c:if test="${(loop.index % 2) eq 0}">
						        	<c:set var="tabColor" value="even"></c:set>
						        </c:if>
						<tr class="${tabColor}">
							<td align="center"> <input type="radio" id="radio${index.index}" name="radio" value="${departmentsList.value.ddId},${departmentsList.value.ddName},${departmentsList.value.ddCode}"/> </td>
							<td> ${departmentsList.value.ddName} </td>
							<td> ${departmentsList.value.ddCode} </td>
						</tr>	
						</c:forEach>	
					</table>
					<table>
						<tr align="left">
							<td colspan="5">
								<input class="formButton ui-corner-all" type="button" value="SELECT" onclick="submitDepartmentDetailsToEdit()" />
							</td>
						</tr>
					</table>
				</div>
			</form>
			
			<c:if test="${resultOfSave}">
				Operation Done Successfully.
			</c:if>
	
			<br>
			<hr/>
			<br>
			
			<form:form commandName="departmentDetailsDTO" id="saveDepartmentDetails">
							<form:hidden path="ddId" id="deparmentId"/>
				<table class="adminFilterTable">
					<tr class="tableChildHeaderColor">
						<th colspan="5" align="center"> Edit Department Details </th>
					</tr>
					<tr class="formSpacingRow"><td></td> </tr>
					<tr class="formSpacingRow"><td></td> </tr>
					<tr>
						<td class="spacingColumnWidthLess"></td>
						<td class="formLabel"> Name* </td>	
						<td class="spacingColumnWidthLess"></td>
						<td class="formField"> <form:input path="ddName" id="departmentName"/> 
							 <form:errors path="ddName" cssClass="errorMsg"/> 
						</td>
						<td class="spacingColumnWidthLess"></td>
					</tr>
					<tr class="formSpacingRow"><td></td> </tr>
					<tr>
						<td class="spacingColumnWidthLess"></td>
						<td class="formLabel"> Code </td>	
						<td class="spacingColumnWidthLess"></td>
						<td class="formField"> <form:input path="ddCode" id="departmentShortName" readonly="true"/> 
							 <form:errors path="ddCode" cssClass="errorMsg"/> 
						</td>
						<td class="spacingColumnWidthLess"></td>
					</tr>
					<tr class="formSpacingRow"><td></td> </tr>
					<tr align="center">
						<td class="spacingColumnWidthLess"></td>
						<td></td>
						<td class="spacingColumnWidthLess"></td>
						<td colspan="2" align="left"> <input class="formButton ui-corner-all" type="button" value="UPDATE" onclick="javascript:addEntity('saveDepartmentDetails')"> </td>
					</tr>
					<tr class="formSpacingRow"><td></td> </tr>
				</table>
			</form:form>
		</c:when>
		<c:otherwise>
			No Records Found.
		</c:otherwise>
	</c:choose>
</div>